﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ARS.Control.Attributes;
using ARS.Control.Custom.Entity.Attributes;
using ARS.Control.Custom.Entity.Fields;
using ARS.Control.Custom.Entity.Forms;

namespace NetWebControl.ControlTest
{
    [ClassTableInfo(Db_Table_Name = "ums_user")]
    public class ums_role
    {

        //private readonly DbSelectHtmlSelect select_RealName = new DbSelectHtmlSelect();

        //public Users()
        //{
        //    this.select_RealName.TableName = "ums_user";
        //    this.select_RealName.DataValueField = "Id";
        //    this.select_RealName.DataTextField = "UMS_Name";
        //}

        [KeyField()]
        public int Id
        {
            get; 
            set;
        }
        [CharField(Verbose_Name = "登录",IsAllowBlank=true)]
        public string UMS_Login
        {
            get;
            set;
        }

        //[ForeignKeyField(Verbose_Name = "选择用户", ListUrl = "AddUndate.aspx")]
        //[SelectDbSelectConfig(TableName = "ums_user", DataTextField = "UMS_Name", DataValueField = "Id")]

        [ChoicesDialogField(Verbose_Name = "abcde", ListUrl = "DataPa.aspx",MaxChoicesNum=1)]
        public int UMS_SecureCode
        {
            get;
            set;
        }

        [ChoicesField(Verbose_Name = "选择性别", Choices = "1|男,0|女",DefaultValue="1")]
        public int UMS_UserType
        {
            get;
            set;
        }

        //[FloatField(Verbose_Name="输入浮点数",DefaultValue="0.0")]
        [BooleanField(Verbose_Name="选择",SelectValue="1",UnSelectValue="0")]
        public string UMS_ProductSystem
        {
            get;
            set;
        }
        //[EmailField(Verbose_Name = "输入邮箱", IsAllowBlank = true)]
        public string UMS_Personnel
        {
            get;
            set;
        }
        //[IntegerField(Verbose_Name="输入整数",DefaultValue="1",IsUnique=true,IsAllowUpdate=true )]
        //public int UMS_UserState
        //{
        //    get;
        //    set;
        //}
        [DateTimeField(Verbose_Name="aa")]
        public string UMS_Name
        {
            get;
            set;
        }

        [PasswordField(Verbose_Name="密码")]
        public string Password
        {
            get;
            set;
        }
    }

    public partial class Mapping : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string c = Request["Checkbox1"];

            //if (IsPostBack)
            //{
            //    string str = Request.Form["entity5"];
            //    int a = 1;
            //}
            ums_role user = new ums_role();
           // user.UMS_EnglishRole = "0";
            this.EntityModifyPanel1.Entity = user;

            this.EntityModifyPanel1.AddEntityToDbEvent += new ARS.Control.Custom.Entity.Widget.EntityControl.AddEntityToDbDelegate(EntityModifyPanel1_AddEntityToDbEvent);
            //this.EntityModifyPanel1.UniqueWhereEvent+=new ARS.Control.Custom.Entity.Widget.EntityModifyPanel.UniqueWhereDelegate(EntityModifyPanel1_UniqueWhereEvent);

            //this.EntityModifyPanel1.AddEntityToDbEvent+=new ARS.Control.Custom.Entity.Widget.EntityControl.AddEntityToDbDelegate(EntityModifyPanel1_AddEntityToDbEvent);
        }

        private string EntityModifyPanel1_AddEntityToDbEvent(ARS.Control.Custom.Entity.Fields.Field controls)
        {
            Response.Write(controls.Value);
            return null;
        }


        //private string EntityModifyPanel1_UniqueWhereEvent(Field field)
        //{
        //    if (field.Db_Field_Name == "UMS_UserState")
        //    {
        //        return "1=0";
        //    }
        //    return "1=1";
        //}

        protected void Button1_Click(object sender, EventArgs e)
        {
            this.EntityModifyPanel1.AddOrUpdateEntityToDb();
            
        }
    }
}